<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<div th:include="common/yljg-modal :: yljg-modal" />
<div th:include="common/common-export :: common-export" />
<title>服务列表</title>
<style type="text/css">

.form-table button{
	margin-top: 6px;
}
.tabs-wrap>.tabs>li>a{
	border-left:1px solid #438EB9!important;
	border-right:1px solid #438EB9!important;
	border-top:1px solid #438EB9!important;
}
</style>
</head>
<script th:inline="javascript">
	/**用户信息*/
	var userInfo = [[${userInfo}]];
</script>
<script type="text/javascript">
$(function() {
	$(this).registerManagerPage();
	enterToQuery(queryForm);
 	initView();
});

function queryForm() {
	$("#fwForm").datagrid("reload");
}

function queryLyForm() {
	$("#fwlyForm").datagrid("reload");
}

function initView()
{
	$("#combogridYljg").combogrid(comboDatagridOption());
	$("#fwForm").datagrid(datagridOption());
	/**查询*/
	$("#btnQuery").on("click", function(){
		queryForm();
	});
	
	/**导出*/
	$("#btnExport").on("click", function(){
		var rows = $("#fwForm").datagrid("getSelections");
		if(rows.length > 0){
			var FWGLIDS = "";
			$(rows).each(function(index, item){
				FWGLIDS+=item["FWGLID"]+",";
			});
			$("#FWGLIDS").val(FWGLIDS.substring(0, FWGLIDS.length-1));
			/**导出必须用submit方法提交，不能用 封装的ajaxsubmit*/
			$("#exportForm").submit();
		}else{
			$.QuickAlert.alertFail({
				content : "请选择要导出的服务！"
			});
		}
	});
	
}

function datagridOption(){
	var opt ={
			idField : "FWGLID",
			uniqueId: "FWGLID",
			striped : true,
			border:false,
			toolbar : $("#dgFormToolbar"),
			columns : [[
				{
					field: "checkStatus",
					checkbox: true
				},
				{
					field : "FWMC",
					width: 150,
					align: "center",
					title : "服务名称"
				},
				{
					field : "TGFWJGMC",
					width: 150,
					align: "center",
					title : "提供服务机构"
				},
				
				{
					field : "YLJGMC",
					width: 150,
					align: "center",
					title : "接收服务机构"
				},
				{
					field : "YLTLXMC",
					width: 100,
					align: "center",
					title : "医联体类型"
				},
				{
					field : "YQFWSJ",
					width: 100,
					align: "center",
					title : "预期服务时间"
				},
				{
					field : "FWNR",
					width: 250,
					align: "center",
					title : "服务内容",
					formatter : function(value, row, index){
						return "<span title='"+value+"'>"+value+"</span>";
					}
				},
				{
					field : "SFSX",
					width: 100,
					align: "center",
					title : "状态",
					formatter : function(value, row, index){
						if(value=="0"){
							return "已新建";
						}else if(value=="1"){
							return "已服务";
						}
					}
				},
				{
					field : "cz",
					width: 100,
					align: "center",
					title : "操作",
					formatter : function(value, row, index) {
						var tool = $("#tableToolBarDetail").html();
						return tool.replace(/#index#/g,index);
					}
				}
			]]
			,pagination : true
			,pageNumber: 1
			,pageSize: 10
			,fit: true
			,fitColumns: true
			,singleSelect: false
			,rownumbers: true
			,method : "post"
			,url: contextRoot+"fwgl/queryPage.service"
			,onBeforeLoad:function(params){
				params["YLJGID"] = $("#combogridYljg").combogrid("getValue");
				params["FWMC"] = $("#FWMC").val();
				params["FWSJ"] = $("#FWSJ").val();
				params["JGXZQHDM"] = userInfo["JGXZQHDM"];
				return params;
			}
		};
		return opt;
}

function comboDatagridOption(lx){
	var opt ={
	        height: 30
	        ,panelWidth: 500
	        ,singleSelect: true
	        ,pagination: true
	        ,idField: 'PTJGID'
	        ,textField: 'YLJGMC'
	        ,mode: "remote"
	        ,url: contextRoot + "yljgxx/queryPage.service"
			,delay: 1000
	        ,reversed: true
	        ,columns:[[
	            {
	                field:'YLJGMC'
	                ,title:'机构名称'
	                ,width:240
	                ,align: 'center'
	            }
	            ,{
	                field:'XZQHMC'
	                ,title:'行政区划'
	                ,width:80
	            }
	            ,{
	                field:'WSJGLBMC'
	                ,title:'机构类别'
	                ,width:80
	            }
	            ,{
	                field:'YYDJMC'
	                ,title:'机构等级'
	                ,width:80
	            }
	        ]]
	        ,onBeforeLoad: function(queryParams) {
	            var url = $(this).datagrid("options")["url"];
				/*URL不等空时再发送请求*/
	            if (!StringUtils.isEmpty(url)) {
	                queryParams["pageSize"] = queryParams["rows"];
	                queryParams["pageNumber"] = queryParams["page"];
	                queryParams["YLJGMC"] = queryParams["q"];
	                return true;
	            }else{
	                return false;
	            }
	        }
			,onChange: function(newValue, oldValue){
	            /*新增响应改变事件*/
	           /*  if(!$("#formYljgry").data("yljgry")){
	                var value = $("#combogridYljg").combogrid("grid").datagrid("getSelected");
	                if(!value){
	                    $("#KS").empty();
	                }else if(value["PTJGID"] != oldValue){
	                    $("#KS").empty();
	                    queryKsxx(value["PTJGID"]);
	                    $("#PTJGID").val(value["PTJGID"]);
	                    $("#YLJGDM").val(value["YLJGDM"]);
	                }
				} */
				
			}
	    };
	return opt;
}

/**详细按钮*/
function detail(index){
	var obj = $("#fwForm");
	/**清除所有选择*/
	$(obj).datagrid("clearSelections");
	/**选中当前行*/
	$(obj).datagrid("selectRow", index);
	/**获取选中行数据*/
	var row = $(obj).datagrid("getSelected", index);
	$.QuickUrlUtils.redirectUrl("fwlbDetail.html?FWGLID="+row["FWGLID"]+"&PTJGID="+row["TGFWJGID"]);
}

</script>

<body >
	<div class="easyui-layout" fit="true">
	    <div region="north" style="border: none; overflow: hidden;">
			<h4 class="h4-title" style="margin:0;padding:0;font-size: 18px;">
				服务列表
			</h4>
		</div>
		<div region="center" style="border: none;" >
			<form id="exportForm" action="export.service" enctype="multipart/form-data">
				<input name="FWGLIDS" id="FWGLIDS" style="display: none;">
				<!-- <input name="TGFWJGID" id="TGFWJGID" style="display: none;">
				<input name="YLJGID" id="YLJGID" style="display: none;"> -->
			</form>
			<div id="dgFormToolbar" style="background: white;">
				<table class="form-table" style="margin:0;padding:0;width:100%">
					<tr>
						<td class="td-text">服务名称：</td>
						<td class="td-content">
							<input id="FWMC" class="form-control" >
						</td>
						</td>
						<td class="td-text">接收服务机构：</td>
						<td class="td-content">
							<input id="combogridYljg" class="form-control dataField"  style="width: 90%;"/>
						</td>
						<td class="td-text">服务时间：</td>
						<td class="td-content">
							 <input id="FWSJ" style="width:85%;height:30px;"
								class="input-text laydate-icon dataField" onclick="laydate()" />
						</td>
						<td class="td-content" style="text-align:center">
							<button id="btnQuery" class="btn btn-info" type="button" >查询</button>
							<button id="btnExport" class="btn btn-info" type="button">导出</button>
						</td>
					</tr>
				</table>
				<!-- <div style="margin:10px 10px auto 0px;">
					<button id="btnExport" class="btn btn-info" type="button">导出</button>
				</div> -->
			</div>
			<div class="easyui-layout" style="border: none;" fit="true">
				<div region="center" style="border: none;">
					<table id="fwForm">
					</table>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/html" id="tableToolBarDetail">
<a class="tableToolBarBtn" href="javascript:detail(#index#)" title="详细" >详细</a>
</script>
</html>



